WPF and Silverlight Edition Basic Library > Menu and ContextMenu > Menu and ContextMenu Elements > Creating Menus |
Complete the following steps:
XAML Copy Code <c1:C1MenuItem Header="MenuItem1" Height="Auto" Width="Auto"/> <c1:C1MenuItem Header="MenuItem2" Height="Auto" Width="Auto"/> <c1:C1MenuItem Header="MenuItem3" Height="Auto" Width="Auto"/>
OR
In this topic, you will create a submenu that's attached to one of a menu's items. This topic assumes that you have created a top-level menu (see Creating a Top-Level Menu) with at least one menu item.
Complete the following steps:
XAML Copy Code <c1:C1MenuItem Header="Click here" Height="Auto" Width="Auto"> <c1:C1MenuItem Header="Submenu Item" Height="Auto" Width="Auto"/> <c1:C1MenuItem Header="Submenu Item" Height="Auto" Width="Auto"/> <c1:C1MenuItem Header="Submenu Item" Height="Auto" Width="Auto"/> </c1:C1MenuItem>
OR
In this topic, you will use the C1ContextMenuService class to attach a context menu to a TextBox control.
Complete the following steps:
XAML Copy Codexmlns:c1="clr-namespace:C1.Silverlight;assembly=C1.Silverlight"
XAML Copy Code <Grid x:Name="LayoutRoot" Background="White"> <TextBox Text="Right-click for context menu" Width="170" Height="25" Background="#FFC4D8D4"> </TextBox> </Grid>
XAML Copy Code <c1:C1ContextMenuService.ContextMenu> </c1:C1ContextMenuService.ContextMenu>
The C1ContextMenuService class exposes context menus as extender properties that can be attached to any FrameworkElement objects on the page.
XAML Copy Code <c1:C1ContextMenu Width="Auto" Height="Auto"> <c1:C1MenuItem Header="MenuItem1"></c1:C1MenuItem> <c1:C1MenuItem Header="MenuItem2"></c1:C1MenuItem> <c1:C1MenuItem Header="MenuItem3"></c1:C1MenuItem> </c1:C1ContextMenu>